package myapp.com.xm.myapplication;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.xm.httpapi.BaseUtils.Toast;

public abstract class OnVerticalScrollListener extends RecyclerView.OnScrollListener {
    @Override
    public final void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
        int firstPos = linearLayoutManager.findFirstVisibleItemPosition();
        int total = linearLayoutManager.getItemCount();

        if (!recyclerView.canScrollVertically(-1)) {
            onScrolledToTop();
        } else if (!recyclerView.canScrollVertically(1)) {
            onScrolledToBottom();
        } else if (dy > 0 ) {//上滑
            onScrolledUp(firstPos,total);
        } else if (dy < 0) {//下滑
            onScrolledDown();
        }
    }

    public void onScrolledUp(int firstPos,int total) {
    }

    public void onScrolledDown() {
    }

    public void onScrolledToTop() {

    }

    public void onScrolledToBottom() {

    }
}
